import Vue from 'vue'
import Vuex from 'vuex'
import api from '@/api/index.js'

Vue.use(Vuex)
let openid=''
if (process.env.NODE_ENV === 'production') {
	openid = ''
}else{
	openid = 'o0qHx5mlneT8siHEvfu2TemPmDDw' //obD_t1CJQMV3LhLx0psum-iUdudI，o0qHx5mlneT8siHEvfu2TemPmDDw
}
export default new Vuex.Store({
  state: {
    code:"",
    access_token:"",
    openid: openid, // obD_t1DQGbgVrCFnluGvhS12uhR8,obD_t1NOwcv_shMMZV4NcblmC7Sk
    appid: "",
    secret: "",
    masterColor: "#335FFC",
    isLogin: false,
    tabbar: [],
    swipeList: [],
    caseTabsList: [],
    caseList: [],
    caseListFinished: false,
    caseItem: "",
    activityItem: "",
    userInfo:'',
    activityData:{},
    activityStatus1:'',
    fansInfo:'',
    myInfo:'',
    minimum:'',
	// ddjy
	selectedCampus:'',
	campusList:[],
	courseList:[{
		id:1,
		cover:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-5ec59f1e-d7e4-40a5-91d6-605747ef2fcc/90c7507e-49fc-4579-bb6e-f99b830c4d34.png',
		title:'党史必修',
		tearcher:'张静',
		school:'南开大学',
		hour:'24',
		inStudy:998,
		type: 2,
		status: 1,
		tag:1
	},{
		id:2,
		cover:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-5ec59f1e-d7e4-40a5-91d6-605747ef2fcc/90c7507e-49fc-4579-bb6e-f99b830c4d34.png',
		title:'12个超经典的时间管理技巧',
		tearcher:'叶朗',
		school:'北京大学同仁校区',
		hour:'24',
		inStudy:998,
		type: 1,
		status: 2,
		tag:2
	},{
		id:3,
		cover:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-5ec59f1e-d7e4-40a5-91d6-605747ef2fcc/90c7507e-49fc-4579-bb6e-f99b830c4d34.png',
		title:'党史必修',
		tearcher:'张路',
		school:'北京师范大学',
		hour:'24',
		inStudy:998,
		type: 3,
		status: 3,
		tag:2
	}],
	courseData:{
		zixun:[{
			id:1,
			cover:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-5ec59f1e-d7e4-40a5-91d6-605747ef2fcc/90c7507e-49fc-4579-bb6e-f99b830c4d34.png',
			title:'饮食疗养法：这4款美食补血又养颜！适合冬季',
			hour:'24',
			read_num:998,
			create_time:'2021-01-12 18:49',
			type: 2,
			status: 1,
			tag:1
		},{
			id:2,
			cover:'',
			title:'12个超经典的时间管理技巧！助你学习效率倍增',
			hour:'24',
			read_num:998,
			create_time:'2021-01-12 18:49',
			type: 2,
			status: 1,
			tag:1
		},{
			id:3,
			cover:'',
			title:'涨~涨~涨！退休人员养老金再上调4.5%，实现17连涨',
			hour:'24',
			read_num:998,
			create_time:'2021-01-12 18:49',
			type: 2,
			status: 1,
			tag:1
		}],
		all:[{
			id:1,
			cover:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-5ec59f1e-d7e4-40a5-91d6-605747ef2fcc/90c7507e-49fc-4579-bb6e-f99b830c4d34.png',
			title:'中华传统文化之戏曲瑰宝',
			address:'平阳电大1号教学楼2004教室',
			tearcher:'张路',
			school:'北京师范大学',
			hour:'24',
			inStudy:998,
			type: 3,
			status: 3,
			tag:2
		},{
			id:2,
			cover:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-5ec59f1e-d7e4-40a5-91d6-605747ef2fcc/90c7507e-49fc-4579-bb6e-f99b830c4d34.png',
			title:'党史必修',
			tearcher:'张静',
			school:'南开大学',
			hour:'24',
			inStudy:998,
			type: 2,
			status: 1,
			tag:1
		},{
			id:3,
			cover:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-5ec59f1e-d7e4-40a5-91d6-605747ef2fcc/90c7507e-49fc-4579-bb6e-f99b830c4d34.png',
			title:'中华传统文化之戏曲瑰宝',
			address:'平阳电大1号教学楼2004教室',
			tearcher:'张静',
			school:'南开大学',
			hour:'24',
			inStudy:998,
			type: 2,
			status: 1,
			tag:1
		}],
		xxCourse:[{
			id:1,
			cover:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-5ec59f1e-d7e4-40a5-91d6-605747ef2fcc/90c7507e-49fc-4579-bb6e-f99b830c4d34.png',
			title:'中华传统文化之戏曲瑰宝',
			address:'平阳电大1号教学楼2004教室',
			tearcher:'张静',
			school:'南开大学',
			hour:'24',
			inStudy:998,
			type: 2,
			status: 1,
			tag:1
		},{
			id:2,
			cover:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-5ec59f1e-d7e4-40a5-91d6-605747ef2fcc/90c7507e-49fc-4579-bb6e-f99b830c4d34.png',
			title:'中华传统文化之戏曲瑰宝',
			address:'平阳电大1号教学楼2004教室',
			tearcher:'叶朗',
			school:'北京大学',
			hour:'24',
			inStudy:998,
			type: 1,
			status: 2,
			tag:2
		},{
			id:3,
			cover:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-5ec59f1e-d7e4-40a5-91d6-605747ef2fcc/90c7507e-49fc-4579-bb6e-f99b830c4d34.png',
			title:'中华传统文化之戏曲瑰宝',
			address:'平阳电大1号教学楼2004教室',
			tearcher:'张路',
			school:'北京师范大学',
			hour:'24',
			inStudy:998,
			type: 3,
			status: 3,
			tag:2
		}],
		zxCourse:[{
			id:1,
			cover:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-5ec59f1e-d7e4-40a5-91d6-605747ef2fcc/90c7507e-49fc-4579-bb6e-f99b830c4d34.png',
			title:'党史必修',
			tearcher:'张静',
			school:'南开大学',
			hour:'24',
			inStudy:998,
			type: 2,
			status: 1,
			tag:1
		},{
			id:2,
			cover:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-5ec59f1e-d7e4-40a5-91d6-605747ef2fcc/90c7507e-49fc-4579-bb6e-f99b830c4d34.png',
			title:'党史必修',
			tearcher:'叶朗',
			school:'北京大学',
			hour:'24',
			inStudy:998,
			type: 1,
			status: 2,
			tag:2
		},{
			id:3,
			cover:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-5ec59f1e-d7e4-40a5-91d6-605747ef2fcc/90c7507e-49fc-4579-bb6e-f99b830c4d34.png',
			title:'党史必修',
			tearcher:'张路',
			school:'北京师范大学',
			hour:'24',
			inStudy:998,
			type: 3,
			status: 3,
			tag:2
		}]
	},
	messageList:[{
		id:1,
		create_time:'2021-01-12 18:49',
		type:1,
		title:'线下课程新增一门《弟子规与人生修炼》，快来看一看吧！'
	},{
		id:2,
		create_time:'2021-01-12 18:49',
		type:2,
		title:'线下课程新增一门《弟子规与人生修炼》，快来看一看吧！'
	},{
		id:3,
		create_time:'2021-01-12 18:49',
		type:3,
		title:'线下课程新增一门《弟子规与人生修炼》，快来看一看吧！'
	}],
	zixunList:[],
	zixunItem:'',
	schoolMsg: {}
  },
  mutations: {
	setSchoolMsg(state, schollDesc) {
		  state.schoolMsg = schollDesc
	  },
	  setZixunItem(state,rawData){
	    state.zixunItem = rawData;
	  },
	  setCampusList(state,rawData){
	    state.campusList = rawData;
	  },
	  setSelectedCampus(state,rawData){
	    state.selectedCampus = rawData;
	  },
    setMininum(state,rawData){
	    state.minimum = rawData;
	  },
    setMyInfo(state,rawData){
	    state.myInfo = rawData;
		state.userInfo = rawData;
		localStorage.setItem('myInfo',JSON.stringify(rawData))
		localStorage.setItem('userInfo',JSON.stringify(rawData))
	  },
    setActivityStatus1(state,rawData){
	    state.activityStatus1 = rawData;
	  },
    setActivityData(state,rawData){
	    state.activityData = rawData;
	  },
    setUserInfo(state,rawData){
	    state.userInfo = rawData;
		state.myInfo = rawData
	  },
    setAccessToken(state,rawData){
	    state.access_token = rawData;
	  },
    setOpenid(state,rawData){
	    state.openid = rawData;
	  },
    setCode(state,rawData){
	    state.code = rawData;
	  },
    setActivityItem(state,rawData){
	    state.activityItem = rawData;
	  },
    setCaseTabsList(state,rawData){
	    state.caseTabsList = rawData;
	  },
    setCaseList(state,rawData){
	    state.caseList = rawData;
	  },
    setCaseListFinished(state, b){
	    state.caseListFinished = b;
	  },
    setCaseItem(state,rawData){
	    state.caseItem = rawData;
	  },
    setSwipeList(state,rawData){
	    state.swipeList = rawData;
	  },
    setAppid(state,rawData){
	    state.appid = rawData;
	  },
    setSecret(state,rawData){
	    state.secret = rawData;
	  },
    setTabbar(state,rawData){
	    state.tabbar = rawData;
	  },
    setColor(state,rawData){
	    state.mainColor = rawData;
      console.log(state.mainColor)
	  },
    setMasterColor(state,rawData){
	    state.masterColor = rawData;
      console.log(state.masterColor)
	  },
  },
  actions: {
    async getCaseList(context,params = {type_id: 0,pageNo: 1,pageSize: 10}){
      await api.getCaseList(params).then(res=>{
        context.commit('setCaseList', res.data);
        return res.data;
      })
    },
  },
  getters: {
    getOpenid(state) {
      return state.openid;
    },
    getAppid(state) {
      return state.appid;
    },
    getSecret(state) {
      return state.secret;
    },
    getMasterColor(state) {
      return state.masterColor;
    },
    getMainColor(state) {
      return state.masterColor;
    },
    getTabbar(state) {
      return state.tabbar;
    },
    getSwipeList(state) {
      return state.swipeList;
    },
    getCaseTabsList(state) {
      return state.caseTabsList;
    },
    getCaseList(state) {
      return state.caseList;
    },
    getCaseListFinished(state) {
      return state.caseListFinished;
    },
    getCaseItem(state) {
      return state.caseItem;
    }
  },
  modules: {
  }
})
